package com.acwing.partition21;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/5/27 10:12
 */
public class AC2049奶牛摄影 {

    private static final int N = 20010;
    private static Integer[] q = new Integer[N];
    private static int[][] p = new int[5][N];
    private static int n;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        for (int i = 0; i < 5; i++) {
            for (int j = 1; j <= n; j++) {
                p[i][nextInt()] = j;
            }
        }
        for (int i = 1; i <= n; i++) q[i] = i;
        //对于每次只考虑两头牛A、B，移动其它牛是不会改变相对顺序，只有把B移到A前面或者把A移到B后面，一共操作5次，如果A在前面的次数大于等于3次，A就在B前面
        Arrays.sort(q, 1, n + 1, (o1, o2) -> {
            int cnt = 0;
            for (int i = 0; i < 5; i++) {
                if (p[i][o1] < p[i][o2]) cnt++;
            }
            return cnt >= 3 ? -1 : 1;
        });
        for (int i = 1; i <= n; i++) writer.println(q[i]);
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
